package com.simon.mengkou.ui.dialog;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupWindow;

import com.simon.mengkou.R;

/**
 * Created by xiazhenshui on 16/6/20.
 */

public class ImageTagEditDialog extends PopupWindow {
    private View.OnClickListener mEditListener;
    private View.OnClickListener mDeleteListener;

    public ImageTagEditDialog(Context context) {
        super(context);

        LayoutInflater inflater = (LayoutInflater)context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.dialog_image_tag_edit, null);
        setContentView(view);

        setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
        setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        setFocusable(true);
        setOutsideTouchable(true);
        //实例化一个ColorDrawable颜色为半透明
        ColorDrawable dw = new ColorDrawable(0x00000000);
        //设置弹出窗体的背景
        this.setBackgroundDrawable(dw);

        view.findViewById(R.id.image_edit_tag_id_edit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(mEditListener != null) {
                    mEditListener.onClick(v);
                }
            }
        });


        view.findViewById(R.id.image_edit_tag_id_delete).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(mDeleteListener != null) {
                    mDeleteListener.onClick(v);
                }
            }
        });
    }


    public void setOnEditListener(View.OnClickListener listener) {
        this.mEditListener = listener;
    }

    public void setOnDeleteListener(View.OnClickListener listener) {
        this.mDeleteListener = listener;
    }
}
